﻿@model StockShark.Models.BrokerageAccount

@{
    ViewBag.Title = "Historia transakcji - " + Model.Name;
    ViewBag.Header = "Historia transakcji - " + Model.Name;
}

@Html.Partial("_BAMenuPartial")

@if (Model.ExecutedTransactions.Count() > 0)
{
<table class="full">
    <tr>
        <th>Typ transakcji</th>
        <th>Walor</th>
        <th>Ilość</th>
        <th>Cena jedn. (PLN)</th>
        <th>Prowizja (PLN)</th>
        <th>Saldo (PLN)</th>
        <th>Wykonano</th>
    </tr>
@foreach (var et in Model.ExecutedTransactions.OrderByDescending(r => r.ExecutionDate))
{
    <tr>
        <td>@(et.BuyNotSell ? "Zakup" : "Sprzedaż")</td>
        <td>@Html.ActionLink(et.Paper.Name, "Details", "Quotations", new { item = et.PaperId }, null)</td>
        <td>@Html.DisplayFor(transactionItem => et.Quantity)</td>
        <td>@Html.DisplayFor(transactionItem => et.UnitPrice)</td>
        <td>@Html.DisplayFor(transactionItem => et.Commission)</td>
        @if (et.BalanceChange > 0)
        {
            <td class="pos">+@Html.DisplayFor(transactionItem => et.BalanceChange)</td>
        }
        else if (et.BalanceChange < 0)
        {
            <td class="neg">@Html.DisplayFor(transactionItem => et.BalanceChange)</td>
        }
        else
        {
            <td>@Html.DisplayFor(transactionItem => et.BalanceChange)</td>
        }
        <td>@Html.DisplayFor(orderItem => et.ExecutionDate)</td>
    </tr>
}
</table>
}
else
{
    <p>Historia transakcji jest pusta.</p>
}
